# !/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time    : 2021/10/9 14:49
# @Author  : zuodengbo
# @Email   : zuodb@amoydx.com
# @File    : fuzzy_query
# @Software: PyCharm
from tortoise.functions import Function
from pypika import CustomFunction


class JsonExtract(Function):
    """
    Json格式模糊查询
    """
    db_func = CustomFunction("JSON_EXTRACT", ["field", "value"])


filters = dict()
annotate = dict()
annotate['json_str'] = JsonExtract('ip', '$')
# filters['json_str__icontains'] = row['ip']

# await model.all().annotate(**annotate).filter(**filters).limit(limit).offset(offset).values()
